$(function () {


    HOME.ajaxHOMEFn({
        url: HOME.baseUrl.detail,
        type: 'POST',
        dataType: 'json',
        data: {
            id: HOME.getQueryVariable('curId')
        }
    }, function (res) {
        $('#goods').html(template('goodsTpl', {'res': res}));
        var windowHeight = $(window).height();
        var mainWrapHeight = $('.free_box').height();
        if(mainWrapHeight < windowHeight - 170){
            $('.free_box').height(windowHeight - 277 + 'px');
        }
    });


    $('body').on('click', '.xx_from', function () {
        if (HOME.getCookierl('HOMEistooken')) {
            // 1:答题 2:视频
            if (HOME.getQueryVariable('typeAssort') == 1) {
                // 1:教学。2:行测
                if (HOME.getQueryVariable('type') == 1) {
                    window.location.href = HOME.locationVal.origin + "/answer.html?type=1&id=" + HOME.getQueryVariable('id') + "&curId=" + HOME.getQueryVariable('curId')
                } else {
                    window.location.href = HOME.locationVal.origin + "/answer.html?type=2&id=" + HOME.getQueryVariable('id') + "&curId=" + HOME.getQueryVariable('curId')
                }
            } else {
                window.location.href = HOME.locationVal.origin + "/videoinfo.html?id=" + HOME.getQueryVariable('id') + "&curId=" + HOME.getQueryVariable('curId')
            }

        } else {
            alert('请登录')
            window.location.href = HOME.locationVal.origin + "/login.html?page=info&id=" + HOME.getQueryVariable('id') + "&type=" + HOME.getQueryVariable('type') + "&typeAssort=" + HOME.getQueryVariable('typeAssort') + "&curId=" + HOME.getQueryVariable('curId')
        }


    })


    $('body').on('click', '.gm_form', function () {
        
        if (HOME.getCookierl('HOMEistooken')) {
                window.open(HOME.locationVal.origin + '/payment.html?id='+ HOME.getQueryVariable('id') + "&type=" + HOME.getQueryVariable('type') + "&typeAssort=" + HOME.getQueryVariable('typeAssort') + "&curId=" + HOME.getQueryVariable('curId'))
        }else {
            alert('请登录')
            window.location.href = HOME.locationVal.origin + "/login.html?page=info&id=" + HOME.getQueryVariable('id') + "&type=" + HOME.getQueryVariable('type') + "&typeAssort=" + HOME.getQueryVariable('typeAssort') + "&curId=" + HOME.getQueryVariable('curId')
        }
    })


})

